

const Pool = require("../../mysql/index");

class UserModel {
    async getAll() {
        return await Pool.query("select * from user");
    }
    async check(username,password) {
        let sql = `SELECT count(id) as count FROM user WHERE username='${username}' AND password='${password}'`
        return await Pool.query(sql)
    }
    async insert(username,password,email,payPassword) {
        let sql = `INSERT INTO user(username,password,email,payPassword) VALUE('${username}','${password}','${email}','${payPassword}')`
        return await Pool.query(sql)
    }
    async getById(id) {
        let sql = `SELECT * FROM user WHERE id=${id}`
        return await Pool.query(sql)
    }
    async getIdByUserPwd(username , pwd) {
        let sql = `SELECT * FROM user WHERE username='${username}' AND password='${pwd}'`
        return await Pool.query(sql)
    }
}

module.exports = new UserModel();